import numpy as np

# 存储全局配置状态的类
class State:
    def __init__(self) -> None:
        # 私有属性只能通过接口访问
        self.__gamma = 1.0
        self.__last_path = ''
        self.__last_dir = ''
        self.__threshold = 127
        self.__dilate_iter = 1
        self.__erode_iter = 1
        self.__opening_iter = 1
        self.__closing_iter = 1
        self.__x = 0
        self.__y = 0
        self.__width = 0
        self.__height = 0
        self.__current_action = 0
        # 状态锁
        self.__lock = False
    
    def set_gamma(self, gamma):
        self.__gamma = gamma

    def get_gamma(self):
        return self.__gamma

    def set_last_path(self, path):
        self.__last_path = path

    def get_last_path(self):
        return self.__last_path

    def set_last_dir(self, dir):
        self.__last_dir = dir

    def get_last_dir(self):
        return self.__last_dir

    def set_threshold(self, threshold):
        self.__threshold = threshold

    def get_threshold(self):
        return self.__threshold

    def set_dilate_iter(self, dilate_iter):
        self.__dilate_iter = dilate_iter

    def get_dilate_iter(self):
        return self.__dilate_iter

    def set_erode_iter(self, erode_iter):
        self.__erode_iter = erode_iter

    def get_erode_iter(self):
        return self.__erode_iter

    def set_opening_iter(self, opening_iter):
        self.__opening_iter = opening_iter

    def get_opening_iter(self):
        return self.__opening_iter

    def set_closing_iter(self, closing_iter):
        self.__closing_iter = closing_iter

    def get_closing_iter(self):
        return self.__closing_iter

    def set_x(self, x):
        self.__x = x

    def get_x(self):
        return self.__x

    def set_y(self, y):
        self.__y = y

    def get_y(self):
        return self.__y

    def set_width(self, width):
        self.__width = width

    def get_width(self):
        return self.__width

    def set_height(self, height):
        self.__height = height

    def get_height(self):
        return self.__height

    def set_current_action(self, action_code):
        self.__current_action = action_code

    def get_current_action(self):
        return self.__current_action

    def __set_lock(self, lock):
        self.__lock = lock

    def lock(self):
        self.__set_lock(True)

    def unlock(self):
        self.__set_lock(False)

    def get_lock(self):
        return self.__lock

    